/*
 * @Descripttion:
 * @version:
 * @Author: ChenXiang
 * @Date: 2021-08-22 11:27:02
 * @LastEditors: ChenXiang
 * @LastEditTime: 2021-08-22 22:28:29
 */
import { TEXT } from './const'
function createElement(type, config, ...children) {
    if (config) {
        delete config.__self;
        delete config.__source;
    }
    console.log('1111', type, config, ...children)
    const props = {
        ...config,
        // defaultProps: {},
        children: children.map(child => typeof child === 'object' ? child : createTextNode(child))// 这一步源码没有，判断是否是对象（说明是dom节点），不是对象的话说明是文本节点，还是转换为对象
    };
    return {
        type,
        props
    }
}


function createTextNode(text) {
    return {
        type: TEXT,
        props: {
            children: [],
            nodeValue: text
        }
    }
}


export default {
    createElement
}